package com.canyou.api;

import com.canyou.enums.ErrorCodeEnum;
import com.canyou.exception.CysBusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 基控制器, 提供获取当前登录用户的相关信息的基本方法
 *
 * @author fy
 * @date 2018-07-09 17:44
 */
@Slf4j
public class BaseApiController {

    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpServletResponse response;

    protected static final String PAGE_INDEX = "1";
    protected static final String PAGE_SIZE = "10";

    protected void redirect(String url) {
        try {
            response.sendRedirect(response.encodeRedirectURL(url));
        } catch (IOException e) {
            throw new CysBusinessException(ErrorCodeEnum.FAIL, e);
        }
    }

}
